package com.platform.qujia.service.impl;


import com.platform.qujia.dao.BusinessAuditMapper;
import com.platform.qujia.pojo.BusinessAudit;
import com.platform.qujia.service.BusinessAuditService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (BusinessAudit)表服务实现类
 *
 * @author makejava
 * @since 2023-12-19 16:26:32
 */
@Service("businessAuditService")
public class BusinessAuditServiceImpl implements BusinessAuditService {
    @Resource
    private BusinessAuditMapper businessAuditMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public BusinessAudit queryById(Long id) {
        return this.businessAuditMapper.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param businessAudit 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<BusinessAudit> queryByPage(BusinessAudit businessAudit, PageRequest pageRequest) {
        long total = this.businessAuditMapper.count(businessAudit);
        return new PageImpl<>(this.businessAuditMapper.queryAllByLimit(businessAudit, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param businessAudit 实例对象
     * @return 实例对象
     */
    @Override
    public BusinessAudit insert(BusinessAudit businessAudit) {
        this.businessAuditMapper.insert(businessAudit);
        return businessAudit;
    }

    /**
     * 修改数据
     *
     * @param businessAudit 实例对象
     * @return 实例对象
     */
    @Override
    public BusinessAudit update(BusinessAudit businessAudit) {
        this.businessAuditMapper.update(businessAudit);
        return this.queryById(businessAudit.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.businessAuditMapper.deleteById(id) > 0;
    }

    @Override
    public BusinessAudit queryLatestAudit(BusinessAudit businessAudit) {
        return this.businessAuditMapper.queryLatestAudit(businessAudit);
    }

    @Override
    public List<BusinessAudit> query(BusinessAudit businessAudit) {
        return this.businessAuditMapper.query(businessAudit);
    }

    @Override
    public List<BusinessAudit> queryByMobilePhone(String mobilePhone) {
        return this.businessAuditMapper.queryByMobilePhone(mobilePhone);
    }

    @Override
    public BusinessAudit getGzhBusinessAudit(BusinessAudit businessAudit) {
        return this.businessAuditMapper.getGzhBusinessAudit(businessAudit);
    }
}
